//
//  NSSegmentedControlViewController.swift
//  MacStudy
//
//  Created by 30san on 2020/9/22.
//  Copyright © 2020 Dawninest. All rights reserved.
//

import Cocoa

class NSSegmentedControlViewController: NSViewController {

    @IBOutlet weak var segmentControl: NSSegmentedControl!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let menu = NSMenu(title: "test")
        menu.addItem(NSMenuItem(title: "标题一", action: #selector(self.clickSeg(_:)), keyEquivalent: ""))
        menu.addItem(NSMenuItem(title: "标题二", action: #selector(self.clickSeg(_:)), keyEquivalent: ""))
        menu.addItem(NSMenuItem(title: "标题三", action: #selector(self.clickSeg(_:)), keyEquivalent: ""))
        segmentControl.setMenu(menu, forSegment: 0)
        segmentControl.showsMenuIndicator(forSegment: 0)
    }
    
    @objc func clickSeg(_ item: NSMenuItem) {
        print(item.title)
    }

    
    @IBAction func clickSegment(_ sender: NSSegmentedControl) {
        print(sender.selectedSegment)
    }
}
